import React from 'react';
import { Switch, Route, Redirect } from 'react-router-dom';
import PrivateRoute from "./utils/PrivateRoute"
//引入组件-使用懒加载
let Login = React.lazy(() => import("./containers/Login/Login"))
let Register = React.lazy(() => import("./containers/Register/Register"))
let List = React.lazy(() => import("./containers/List/List"))
let Search = React.lazy(() => import("./containers/Search/Search"))
let Index = React.lazy(() => import("./containers/Index/Index"))
let Detail = React.lazy(() => import("./containers/Detail/Detail"))



function App() {
  return (
    <div className="App">
      <React.Suspense fallback={<div>正在加载中。。。。</div>}>
        <Switch>
          <Route path="/login" component={Login} mate={{ title: "手机登录" }}></Route>
          <Route path="/register" exact strict component={Register}></Route>
          <PrivateRoute path="/index" component={Index}></PrivateRoute>
          <PrivateRoute path="/list" component={List}></PrivateRoute>
          <PrivateRoute path="/search" component={Search}></PrivateRoute>
          <PrivateRoute path="/detail" component={Detail}></PrivateRoute>
          <Redirect to="/login"></Redirect>
        </Switch>
      </React.Suspense>
    </div>
  );
}

export default App;
